package com.smartstate.dataManagement.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smartstate.dataManagement.dto.PageDTO;
import com.smartstate.dataManagement.entity.Permission;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface PermissionMapper extends BaseMapper<Permission> {
    @Select("select * from permission")
    List<Permission> findAll();

    @Select("select   PERM_ID  from role_permission where role_id=#{roleId}")
    List<String> getPerIdByRoleId(@Param("roleId") String roleId);

    List<Permission> getPerById(@Param("roleId") String id);


    int addPermission(Permission permission);

    List<Permission> getPermByNameAndStatus(String username,String status);

    List<String> getPermIdsByRoleId(List<String> roleId);

    List<Permission> getPermsList(List<String>  ids);

    int  addChild(Permission permission);

    int updateByPermID(Permission permission);

    int deletezPermById(@Param("id") String id);

    @Update("update  permission set  state=#{status},UPDATE_USER=#{updateUser},UPDATE_TIME=#{updateTime} where id=#{id}")
    int updateStatuByID(@Param("id") String id ,@Param("status") String status,@Param("updateUser") String updateUser,@Param("updateTime") String updateTime);

    int delBatchByIDs(List<String> ids);

    @Select("select  * from  permission where  parentId=#{id}")
    List<Permission> lazyLoadMeun(@Param("id") String id);

    int addBatchByIDs(List<Permission> permissionList);

    @Select("select  * from permission  where name=#{name}")
    Permission getPerm(@Param("name") String name);

    @Select("select  * from permission where parentId=#{parentId}")
    List<Permission> getListByParentId(@Param("parentId") String parentId);

    @Select("select  * from permission where parentId !='0'")
    List<Permission> getNoBaseList();

    List<Permission> findPermissionByUserId(String id);
}
